import axios from "../utils/axios";

export const addFriendsApi = (data: { toUserId: number; reason: string }) => {
  return axios.post("friends-ship", {
    toUserId: data.toUserId,
    reason: data.reason,
  });
};

// 搜索好友
export const getFriendsListApi = (username: string) => {
  return axios.get<IUser[]>("friends-ship/search", { params: { username } });
};

export const getRequstListApi = () => {
  return axios.get<IRequire[]>("friends-ship/getUserRequestList");
};

// 同意好友的请求
export const agreeFriendsApi = (id: number) => {
  return axios.get(`friends-ship/agree/${id}`);
};

// 拒绝
export const refuseFriendsApi = (id: number) => {
  return axios.get(`friends-ship/refuse/${id}`);
};

// 获取好友列表
export const getFriendsApi = () => {
  return axios.get<IUser[]>("friends-ship");
};
